﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Entity;
using BusinessObject;

namespace GreenLife.Admin
{
    public partial class ChinhSuaDanhMuc : System.Web.UI.Page
    {
        DataSet ds;
        Category c;
        CategoriesBO cBO = new CategoriesBO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                selectCategoryByID();
            }
        }

        public void selectCategoryByID()
        {
            c = new Category();
            int id = Int32.Parse(Request.QueryString["idc"]);
            c = cBO.selectCategoryByID(id);
            txtID.Text = c.Category_ID.ToString();
            txtName.Text = c.Category_Name.ToString();
            txtDesc.Text = c.Category_Description.ToString();
            ddlType.SelectedValue = c.Category_Type.ToString();
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            c = new Category();
            c.Category_ID = Int32.Parse(txtID.Text);
            c.Category_Name = txtName.Text;
            c.Category_Description = txtDesc.Text;
            c.Category_Type = ddlType.SelectedValue.ToString();
            if (cBO.updateCategory(c))
            {
                Response.Redirect("DanhSachDanhMuc.aspx");
            }
        }
    }
}